package com.librelato.tela.datamodel;

import java.util.List;

import javax.faces.model.ListDataModel;

import org.primefaces.model.SelectableDataModel;

import com.librelato.bean.CentroCustoBean;

public class CCustoDataModel extends ListDataModel<CentroCustoBean> implements
		SelectableDataModel<CentroCustoBean> {
	
	public CCustoDataModel(List<CentroCustoBean> data) {
		super(data);
	}

	@SuppressWarnings({ "unchecked" })
	@Override
	public CentroCustoBean getRowData(String linha) {
		List<CentroCustoBean> ccs = (List<CentroCustoBean>) getWrappedData();
		for(CentroCustoBean cc : ccs){
			if(cc.getCodigo().equals(linha)){
				return cc;
			}
		}
		return null;
	}

	@Override
	public Object getRowKey(CentroCustoBean linha) {
		return linha.getCodigo();
	}
	
	

}
